package com.snow.useviewdemo.function.wallpaper;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.snow.common.tool.utils.ToastUtils;
import com.snow.useviewdemo.MainActivity;
import com.snow.useviewdemo.R;
import com.snow.useviewdemo.base.BaseActivity;
import com.snow.useviewdemo.databinding.ActivityPhoneAppsBinding;
import com.snow.useviewdemo.databinding.ActivityWallpagerSettingBinding;
import com.snow.useviewdemo.function.phonesystem.PhoneAppInfoBean;
import com.snow.useviewdemo.util.PhoneAppUtils;
import com.snow.useviewdemo.util.TextViewUtils;

import java.util.List;

/**
 * Created by zhaoyingtao
 * Date: 2020/7/18
 * Describe:壁纸设置
 */
public class WallpagerSettingActivity extends BaseActivity<ActivityWallpagerSettingBinding> {
    private int WALLPAPER_REQUESTCODE = 2345;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_wallpager_setting;
    }

    @Override
    protected void setViewData(Bundle savedInstanceState) {
        boolean isSupport = SZWallpaperUtils.isSupportWallpaper(this);
        mBinding.textView.setText("是否支持壁纸设置：" + isSupport);
        mBinding.settingBtn.setOnClickListener(view -> {
            if (isSupport) {
                SZWallpaperUtils.setLiveWallpaper(WallpagerSettingActivity.this, WALLPAPER_REQUESTCODE);
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == WALLPAPER_REQUESTCODE) {
            if (resultCode == Activity.RESULT_OK) {
                ToastUtils.getInstance().showToast("设置成功");
            } else {
                ToastUtils.getInstance().showToast("设置失败");
            }
        }
    }
}
